package t2jumble;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import Sequenic.T2.Seq.Trace;

/**
 * Associates a T2 trace with the results of it being applied against a set of Jumble mutations.
 */
public class TraceResult implements Comparable<TraceResult> {
	private Trace mTrace;
	private Set<Integer> mMutationsCaught;
	private int mMutationPoints;
	
	/**
	 * @param trace T2 trace
	 * @param score used for sorting/ranking the trace, a higher score indicates that the trace is more preferred
	 */
	public TraceResult(Trace trace, Iterable<Integer> mutationsCaught, int mutationPoints) {
		mTrace = trace;
		mMutationsCaught = new HashSet<Integer>();
		for (Integer mutationPoint : mutationsCaught) {
			mMutationsCaught.add(mutationPoint);
		}
		mMutationPoints = mutationPoints;
	}
	
	public int getMutationPoints() {
		return mMutationPoints;
	}
	
	public Set<Integer> getMutationsCaught() {
		return Collections.unmodifiableSet(mMutationsCaught);
	}
	
	public int getScore() {
		return mMutationsCaught.size();
	}
	
	public Trace getTrace() {
		return mTrace;
	}

	@Override
	public int compareTo(TraceResult o) {
		return o.getScore() - this.getScore();
	}

	@Override
	public String toString() {
		return String.format("%03d/%03d (%s)", getScore(), getMutationPoints(), Util.join(mMutationsCaught, ", "));
	}
	
	
	
}
